<!DOCTYPE html>
<html  xmlns:th="http://www.thymeleaf.org">
<!--引入header中 公共导航部分 -->
<head th:replace="header::header-commo(首页)">
</head>


<body>
<!--引用公共搜索栏部分-->
<header th:replace="header::header-nav">
</header>

<div class="container" style="margin-top:25px;">
    <!-- #maps.isEmpty(session.cart.cartItems) : 判断购物车中商品数量是否为空-->
    <div th:if="${session.cart==null or #maps.isEmpty(session.cart.cartItems)}" class="jumbotron">
        <p class="text-center">
            您的购物车中还没有商品,
            <a class="" th:href="@{/}" href="${pageContext.request.contextPath}/"> 去逛逛吧</a>
        </p>
    </div>

    <div th:if="${session.cart!=null}" class="panel panel-success">
        <!-- Default panel contents -->
        <div class="panel-heading">
            <h3 class="panel-title">我的购物车</h3>
        </div>
        <!-- Table -->
        <table class="table table-condensed text-center table-responsive">
            <thead>
            <tr>
                <th class="text-center">图片</th>
                <th class="text-center">商品</th>
                <th class="text-center">单价(元)</th>
                <th class="text-center">数量</th>
                <th class="text-center">小计</th>
                <th class="text-center">操作</th>
            </tr>
            </thead>
            <tbody>
            <!--entry 取的是session的值-->
            <tr th:each="entry : ${session.cart.cartItems}">
                <td><img th:src="@{'/upload/'+${entry.value.item.image }}" src="img/goods1.jpg" class="buyimg"/></td>
                <td th:text="${entry.value.item.name}">提莫 手办</td>
                <td th:text="'¥'+ ${entry.value.item.shopPrice}"> ¥150.00</td>
                <td style="vertical-align: middle">
                    <div class=" input-group col-md-3 " style="margin:  0 auto;">
                        <span class="input-group-addon" >-</span>
                        <input style="width: 50px;" name="count js-buy-num"  th:value="${entry.value.count}" type="text" class="form-control text-center" value="1">
                        <span class="input-group-addon "  >+</span>
                    </div>
                </td>
                <td th:text="'¥'+${entry.value.subtotal}">¥150.00</td>
                <td>
                    <a href="#" th:href="@{/cart/delete/{id}(id=${entry.value.item.id})}">删除</a>
                </td>
            </tr>

            </tbody>
        </table>
    </div>
    <div class="text-right">
        商品金额：<span class="xiangq_font3" th:text="'¥'+${session.cart.total}">¥350.00元</span>
    </div>
    <div class="text-right"
         style="border-bottom: 1px solid #DDDDDD;border-top: 1px solid #DDDDDD; margin-top: 10px;padding:5px 0 5px 0;">
        <a class="btn  btn-danger btn-lg" th:href="@{/cart/clear}"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span>清空购物车</a>
        <a class="btn  btn-success btn-lg" th:href="@{/order/creat}" href="#" role="button">提交订单</a>
    </div>

</div>

<!--底部-->
<footer th:replace="footer::footer-comm">
</footer>


</body>

</html>